package com.groupbuying.settleconsumer.common;

import com.groupbuying.settleconsumer.service.SettleService;
import org.springframework.util.Assert;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 分账策略工厂类,根据不同渠道设置不同的分账规则
 * author cuich
 * tar 调用方(OrderSettlementServiceImpl)
 * date 2019/12/2 10:16 上午
 * @apiGroup SettleConsumer
 * @apiVersion 1.0.0
 */
public class SettleServiceStrategyFactory {

    private static Map<String,SettleService> service = new ConcurrentHashMap<>();

    public static SettleService getBySettleType (String settleType){
        return service.get(settleType);
    }

    public static void register(String settleType,SettleService settleService){
        Assert.notNull(settleType,"settleType can't be null");
        service.put(settleType,settleService);
    }

}
